/**
 * Created by fszer on 16-2-22.
 */


const webpack           = require('webpack'),
      path              = require('path'),
      ExtractTextPlugin = require('extract-text-webpack-plugin');

(()=> {

    "use strict";
    module.exports = {
        entry: [
            path.resolve(__dirname, './src/app.js')],
        output: {
            path: path.resolve(__dirname, './dist/'),
            filename: 'app.js'
        },
        resolve: {
            extensions: ['', '.js', '.vue'],
            alias: {
                'src': path.resolve(__dirname, './src'),
                jQuery: path.resolve(__dirname, './node_modules/jquery/dist/jquery'),
                configs:path.resolve(__dirname, './config.js')
            }
        },
        resolveLoader: {
            root: path.join(__dirname, 'node_modules')
        },
        module: {
            loaders: [{test: /\.vue$/, loader: 'vue'},
                {
                    test: /\.js$/,
                    loader: 'babel',
                    exclude: /node_modules/
                },
                {
                    test: /\.(ttf|eot|svg|woff(2)?)(\?.*)?$/,
                    loader: 'file-loader?./static/name=[name].[ext]'
                },
                {
                    test: /\.(png|jpg|gif|svg)$/, loader: "url",
                    query: {
                        limit: 1,
                        name: './static/images/[name].[ext]?[hash:7]'
                    }
                },
                {
                    test: /\.html$/,
                    loader: 'file-loader?name=[name].[ext]'
                },
                {
                    test: /\.css$/,
                    loader: ExtractTextPlugin.extract('style', 'css!sass')
                }]
        },
        vue: {
            loaders: {
                js: 'babel',
                css: ExtractTextPlugin.extract("css"),
                sass: ExtractTextPlugin.extract('style', 'css!sass')
            }
        },
        babel: {
            presets: ['es2015'],
            plugins: ['transform-runtime']
        },
        plugins: [new ExtractTextPlugin("app.css"),
            new webpack.ProvidePlugin({
                $: "jquery",
                _:'lodash',
                m:'moment',
                util:'configs',
                yaku:"yaku"
            }),
             new webpack.optimize.OccurenceOrderPlugin(),
            new webpack.optimize.UglifyJsPlugin({
                compress: {
                    warnings: false
                }
            })]
    };
})();
